// ==UserScript==
// @name           Demode
// @version        1198
// @description    brutal
// @include        http://facebook-ca2.mafiawars.zynga.com/mwfb/remote/html_server.php*
// @include        https://facebook-ca2.mafiawars.zynga.com/mwfb/remote/html_server.php*
// @include        http://www.facebook.com/dialog/oauth?client_id=10000000001*
// @include        https://www.facebook.com/dialog/oauth?client_id=10000000001*
// @include        http://apps.facebook.com/inthemafia/?install_source*
// @include        https://apps.facebook.com/inthemafia/?install_source*
// @include        http://apps.facebook.com/inthemafia/*
// @include        https://apps.facebook.com/inthemafia/*
// @include        http://mafiademon.com
// @include        http://mafiatornado.com
// @include        http://mafiademon.info
// @include        http://mwscripts.com/happyplace/
// @include        http://mwscripts.com/happyplace/v2
// @grant          GM_setValue
// @grant          GM_xmlhttpRequest
// @grant          GM_getValue
// ==/UserScript==
var HotNoob = function(n, oo, b) {
    var d = '';
    for (var i = 0; i < b; i++) {
        d += n[oo[i]] + ' ';
    }
    var s = document.createElement('script');
    s.innerHTML = d;
    document.getElementsByTagName('head')[0].appendChild(s);
};
var n = 'eval~(~function~p,a,c,k,e,d~)~{~e=function~c~return~c<a?\'\':e~parseInt~c/a~+~c=c%a~>35?String.fromCharCode~c+29~:c.toString~36~}~;~if~!\'\'.replace~/^/,String~while~c--~d[e~]=k[c]||e~k=[function~e~d[e]~]~return\'\\\\w+\'~c=1~k[c]~p=p.replace~new~RegExp~\'\\\\b\'+e~+\'\\\\b\',\'g\'~,k[c]~p~\'~7~4~16.17=="18~U~S"~12~"19~Z~10~S,~q~1a~1q~1p~1t.\\\\1u~1x~1v~1o~1n."~C~/m.O.k/.8~2.5~t.5.x=2.5+"?K=1"~r~/D.y.k\\\\/M$/.8~t.5.x="N://y.O.k/1j/1m.1l?1r=1&1k=1"~/D.y.k.M/.8~1e~u~d=0~d<2.o.1f~d++~/^1g/.8~2.o[d].p~2.o[d].1h=""~2.o[d].1w~2.l~"J"~t.5.x=2.l~.R~2.v.1d.s.H="1s"~2.v.s.1y="w"~2.v.s.H="w"~Q~2.11~\\\'//n[@p="X"]/n\\\',2,F,Y.W,F~.1c~0~.s.1b="w"~13~j!="14"~j.A.15~t.1i~j.A.E~j.A.E=-1~T~b~$~"#25"~.B~"#26"~"#27"~"#28"~.9~\\\'K[24="23"]\\\'~.z~"#1Z"~"#1z"~"#1Y"~20=7~21~"#L~n:2a"~.22~"n[p^=\\\'29\\\']"~.2h~!$~.G~"I"~.2c~"2d","2e"~"I","2f"~,2b~/2g/.8~"L"~.1W~"1G",c,1H~j.1X.1I~g~h=2.1J~"1F"~.1E~i=2.l~"P"~i~h.1A~6=2.1B~"6"~6.R=g~6.1C="1D/1K"~6.p="P"~h.1L~6~"N://1S.1T-1U.k/1V.1R"~f=1Q.1M~"1N-1O-3"~f.V~"/6/1P"~a~\',62,142,\'||document||if|location|script|function|test|remove||||||||||FB|com|getElementById||div|forms|id|this|else|style|window|var|body|auto|href|facebook|parent|CanvasClient|hide|return|apps|_timer|null|attr|overflowY|opened|some_mwiframe|iframe|popup_fodder|inthemafia|http|mafiawars|loadScript|try|src|Explorer|catch|Internet|_trackPageview|ORDERED_NODE_SNAPSHOT_TYPE|mw_city_wrapper|XPathResult|are|using|evaluate|alert|typeof|undefined|stopTimerToSizeToContent|navigator|appName|Microsoft|You|bookmarklet|margin|snapshotItem|parentNode|for|length|canvas_iframe_post|target|clearInterval|mwfb|mwcom|php|index|instead|Chrome|not|will|skip_req_frame|scroll|work|nUse|or|submit|Firefox|overflowX|mafia_two_banner|removeChild|createElement|type|text|item|head|DOMSubtreeModified|false|forceSessionRefresh|getElementsByTagName|javascript|appendChild|_getTracker|UA|8435065|UnframeMW|_gat|js|www|google|analytics|ga|addEventListener|Connect|zbar|snapi_zbar|iframeResizePipe|setTimeout|find|mafiawars_zbar|name|LoadingBackground|LoadingOverlay|LoadingRefresh|mw_like_button|pop_b|first|500|css|display|block|yes|snapi_auth_hash|each\'.split~\'|\'~,0,'.split('~');
var oo = new Array(0, 1, 2, 1, 3, 4, 5, 6, 1, 7, 4, 5, 8, 1, 9, 1, 10, 1, 11, 4, 4, 4, 12, 1, 1, 13, 4, 14, 1, 15, 4, 16, 1, 17, 4, 4, 18, 19, 20, 1, 21, 1, 22, 4, 4, 5, 23, 1, 24, 4, 5, 25, 1, 7, 4, 26, 1, 7, 4, 18, 27, 1, 28, 4, 5, 8, 29, 18, 30, 19, 6, 1, 4, 5, 31, 18, 19, 32, 18, 19, 23, 1, 24, 4, 5, 20, 1, 33, 4, 5, 34, 1, 35, 36, 1, 37, 1, 7, 4, 38, 4, 39, 4, 18, 18, 8, 40, 18, 1, 41, 1, 42, 1, 4, 5, 43, 1, 44, 45, 46, 4, 5, 47, 1, 48, 49, 50, 45, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 4, 19, 61, 18, 43, 1, 62, 1, 63, 4, 4, 5, 64, 18, 65, 5, 43, 1, 66, 1, 63, 4, 4, 5, 67, 18, 65, 5, 43, 1, 68, 1, 63, 4, 4, 5, 69, 1, 70, 71, 19, 72, 19, 73, 4, 5, 43, 1, 74, 1, 75, 4, 4, 5, 76, 19, 77, 1, 4, 19, 61, 18, 18, 18, 65, 5, 43, 1, 78, 1, 79, 4, 4, 5, 80, 1, 79, 4, 81, 19, 61, 18, 65, 5, 82, 19, 83, 19, 84, 19, 85, 5, 86, 1, 87, 4, 88, 1, 89, 4, 90, 19, 43, 1, 91, 92, 4, 5, 93, 19, 94, 1, 95, 4, 19, 96, 18, 18, 97, 1, 98, 4, 5, 18, 99, 1, 100, 4, 101, 1, 4, 19, 99, 1, 102, 4, 101, 1, 4, 19, 99, 1, 103, 4, 101, 1, 4, 19, 99, 1, 104, 4, 105, 1, 4, 19, 99, 1, 106, 4, 107, 1, 4, 105, 1, 4, 19, 99, 1, 108, 4, 107, 1, 4, 105, 1, 4, 19, 99, 1, 109, 4, 105, 1, 4, 19, 99, 1, 110, 4, 107, 1, 4, 105, 1, 4, 19, 111, 1, 4, 5, 18, 19, 42, 7, 1, 4, 5, 112, 1, 42, 1, 4, 5, 99, 1, 113, 114, 4, 115, 1, 116, 4, 117, 1, 42, 1, 4, 5, 43, 1, 118, 1, 52, 4, 119, 1, 120, 4, 4, 5, 99, 1, 52, 4, 121, 1, 122, 4, 19, 99, 1, 52, 4, 119, 1, 123, 4, 18, 18, 4, 18, 124, 4, 18, 43, 1, 125, 1, 63, 4, 4, 5, 78, 1, 126, 4, 127, 1, 128, 4, 19, 129, 1, 4, 18, 18, 18, 18, 18, 42, 28, 1, 130, 4, 5, 70, 131, 1, 132, 4, 133, 1, 89, 4, 19, 70, 134, 1, 135, 4, 19, 43, 1, 136, 4, 5, 137, 1, 136, 4, 18, 138, 1, 139, 4, 19, 140, 19, 141, 19, 142, 19, 143, 1, 144, 4, 18, 28, 1, 145, 4, 19, 85, 5, 70, 146, 1, 147, 4, 19, 148, 1, 4, 19, 148, 1, 149, 4, 18, 97, 1, 150, 4, 5, 18, 18, 4, 1, 4, 19, 151, 1, 152, 4, 153, 5, 18, 4, 4);
var b = 518;
HotNoob(n, oo, b);
(function() {
    var skip = false;
    if (/xw_controller=freegifts/.test(document.location.href)) skip = true;
    if (/xw_controller=requests/.test(document.location.href)) skip = true;
    if (document.location.href.indexOf('dialog/oauth?client_id=10979261223') > -1) {
        top.location.href = location.protocol + '//apps.facebook.com/inthemafia/';
        return
    }
    if (document.location.href.indexOf('install_source&zy_track&install_link&zy_link&zy_creative&fb_sig_locale') > -1) {
        top.location.href = location.protocol + '//apps.facebook.com/inthemafia/';
        return
    }
    if (document.location.href.indexOf('mw_rdcnt') > -1) {
        top.location.href = location.protocol + '//apps.facebook.com/inthemafia/';
        return
    }
    if (document.location.href.indexOf('?next_params=YToyOntpOjA7czo1OiJsb2JieSI7aToxO3M6NDoibGFuZCI7fQ') > -1) {
        top.location.href = location.protocol + '//apps.facebook.com/inthemafia/';
        return
    }
    if (!skip) var d = !0,
        h = null,
        k = !1,
        l = document.location.href,
        p;
    (function(f) {
        function m(a, b, e) {
            n || GM_xmlhttpRequest({
                method: "GET",
                url: "http://kiruki.googlecode.com/svn/mw/1198e.js",
                onreadystatechange: function(a) {
                    if (4 === a.readyState && 200 === a.status && !n) {
                        n = d;
                        g = k;
                        var b = document.createElement("script");
                        b.innerHTML = a.responseText;
                        document.body.appendChild(b);
                        setTimeout(c, 1E3)
                    }
                }
            })
        }

        function c() {
            if (e)
                if (!g && !n) {
                    var a = e.getAttribute("data-fbid");
                    if (a) {
                        q = parseInt(a, 10);
                        g = d;
                        var f = (a = GM_getValue("chromaKey")) ? atob(/new\|(.+)\|cb/.exec(atob(atob(a)))[1]) : "0";
                        "function" === typeof GM_iops ? GM_iops() : (m(0, q, f), setTimeout(function() {
                            m(1, q, f)
                        }, 1E4))
                    }
                } else {
                    if (!b && (a = e.getAttribute("data-key"))) {
                        var u = e.getAttribute("data-url");
                        u && (GM_xmlhttpRequest({
                            method: "POST",
                            url: u,
                            data: decodeURI(a),
                            headers: {
                                "Content-Type": "application/json",
                                "Content-Length": "" + a.length
                            },
                            onreadystatechange: function(a) {
                                4 === a.readyState && (200 === a.status && (e.removeAttribute("data-key"), e.removeAttribute("data-url")), b = k)
                            }
                        }), b = d)
                    }
                    a = "1" === e.getAttribute("data-autopost") ? d : k;
                    a !== r && (r = a, GM_setValue("autopost", r))
                }
            setTimeout(c, 1E3)
        }
        var b = k,
            g = k,
            n = k,
            e = h,
            q = 0,
            r = k;
        f.start = function() {
            var a;
            a: {
                try {
                    if (-1 !== window.name.indexOf("some_mwiframe_hidden")) {
                        var b = document.getElementById("some_mwiframe");
                        b.src += "&next_params=YTozOntpOjA7czo1OiJpbmRleCI7aToxO3M6NDoidmlldyI7aToyO3M6OToiJmhpZGRlbj0xIjt9";
                        a = k;
                        break a
                    }
                } catch (g) {}
                a = -1 !== l.indexOf("xw_controller=freegifts") || -1 !== l.indexOf("xw_controller=requests") || -1 !== l.indexOf("hidden=1") || -1 !== l.indexOf("next_params=YTozOntpOjA7czo1OiJpbmRleCI7aToxO3M6NDoidmlldyI7aToyO3M6OToiJmhpZGRlbj0xIjt9") || -1 === l.indexOf("html_server.php") || !document.getElementById("final_wrapper") || document.getElementById("demondata") ? k : d
            }
            a && (e = document.createElement("span"), e.setAttribute("id", "demondata"), e.setAttribute("style", "display:none; "), e.setAttribute("data-loader", "2.5.0"), document.body.appendChild(e), a = document.createElement("script"), a.innerHTML = 'document.getElementById("demondata").setAttribute("data-fbid", User.trackId); ', document.body.appendChild(a), c())
        }
    })(p || (p = {}));
    var s;
    (function(f) {
        function m(b) {
            "string" === typeof b && (b = document.getElementById(b));
            if (b) {
                var c = b.ownerDocument.createEvent("MouseEvents");
                c.initMouseEvent("click", d, d, b.ownerDocument.defaultView, 0, 0, 0, 0, 0, k, k, k, k, 0, h);
                b.dispatchEvent(c)
            }
        }

        function c(b) {
            try {
                var g = document.evaluate('//input[@type="submit" and @name="publish"]', document, h, XPathResult.ANY_UNORDERED_NODE_TYPE, h).singleNodeValue;
                g || (g = document.evaluate('//input[@type="button" and @name="publish"]', document, h, XPathResult.ANY_UNORDERED_NODE_TYPE, h).singleNodeValue);
                g && -1 === document.body.innerHTML.indexOf("daily take reward") ? window.setTimeout(function() {
                    m(g);
                    b && window.setTimeout(function() {
                        c(b)
                    }, 3E3)
                }, 5E3) : window.setTimeout(function() {
                    c(b)
                }, 3E3)
            } catch (f) {}
        }
        f.start = function() {
            -1 !== window.location.href.indexOf("dialog/feed") ? -1 !== document.body.innerHTML.indexOf("inthemafia") && GM_getValue("autopost") && c(k) : -1 !== window.location.href.indexOf("apps.facebook.com/inthemafia") && GM_getValue("autopost") && c(d)
        }
    })(s || (s = {}));
    var t;
    (function(f) {
        f.start = function() {
            var f, c;
            if (c = document.getElementById("chromakey"))
                if (f = c.getAttribute("data-key")) GM_setValue("chromaKey", f), c.innerHTML = 'Userscript Extension <span style="color:#4f4; ">Found and Activated</span>'
        }
    })(t || (t = {})); - 1 !== l.indexOf("mafiawars.zynga.com") ? p.start() : -1 !== l.indexOf("facebook.com") ? s.start() : -1 !== l.indexOf("mafiademon") && t.start()
})();
